package com.imooc.business.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author Tim
 * @Description: 跨域配置
 * @Version 1.0
 */
@Configuration
public class CrosConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                //只允许这个域名跨域访问
                .allowedOrigins("http://localhost:9999")
                .allowedMethods(HttpMethod.GET.name(), HttpMethod.POST.name());
    }

}
